package com.xiaoke.liantongdemo.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;
import android.widget.Button;

import com.xiaoke.liantongdemo.R;
import com.xiaoke.liantongdemo.constants.Constants;

public class BusinessDetailActivity extends Activity {
	
	private WebView content;
	private Button manage;
	
	private int businessId;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		businessId = getIntent().getIntExtra(Constants.PARAM_NAME_BUSINESS_ID, 0);
		String contentPath = "file:///mnt" + Constants.DATA_PATH + Constants.BUSINESS_HTML_PATH + businessId + Constants.HTML_SUFFIX;
		setContentView(R.layout.business_detail);
		content = (WebView) findViewById(R.id.detail_content);
		manage = (Button) findViewById(R.id.manage_bt);
		content.loadUrl(contentPath); 
		manage.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(BusinessDetailActivity.this, BusinessInputActivity.class);
				intent.putExtra(Constants.PARAM_NAME_BUSINESS_ID, businessId);
				startActivityForResult(intent, Constants.REQUEST_CODE_MANAGE);
				
			}
		});
	}
	
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if(resultCode == Constants.RESULT_CODE_MANAGED){
			setResult(Constants.RESULT_CODE_MANAGED);
			finish();
		}
	}

}
